

//
//  ZTSiginWebViewController.m
//  ZTTaxSecond
//
//  Created by Zhengtong on 15/12/9.
//  Copyright © 2015年 Zhengtong. All rights reserved.
//

#import "ZTSiginWebViewController.h"
#import <WebKit/WebKit.h>
#import "ZTTabBarController.h"
@interface ZTSiginWebViewController ()<UIWebViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (nonatomic, strong) JSContext *jsContext;
@end

@implementation ZTSiginWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpNavgationBar];
    
//        NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
//        NSString* appHtml = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
//        NSURL *baseURL = [NSURL fileURLWithPath:htmlPath];
//        [self.webView loadHTMLString:appHtml baseURL:baseURL];
    
//    WKWebView *wkWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
//    
//    [wkWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.0.118:8080/e2g-web/org/orgUser/registered.do"]]];
//    [self.view addSubview:wkWebView];
    
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.0.118:8080/e2g-web/org/orgUser/registered.do"]]];
    
 
}
#pragma mark - 设置导航条
- (void)setUpNavgationBar
{
    self.title = @"注册";
    
    self.automaticallyAdjustsScrollViewInsets = YES;
    
    self.navigationController.navigationBar.hidden = NO;
    //导航条背景图片
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"上栏"] forBarMetrics:UIBarMetricsDefault];
    //导航标题颜色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    UIBarButtonItem *backBtnItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithOriginalName:@"返回按钮.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBtnClick)];
    self.navigationItem.leftBarButtonItem = backBtnItem;
}
- (void)leftBtnClick
{
    [self.navigationController popViewControllerAnimated:NO];
}

-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType

{
    NSString *urlstr = request.URL.absoluteString;
    
    NSRange range = [urlstr
                     rangeOfString:@"taxplat://"];
    
    if (range.length!=0) {
        
        NSString *method = [urlstr substringFromIndex:(range.location+range.length)];
        
        SEL selctor = NSSelectorFromString(method);

        [self performSelector:selctor withObject:nil];
        
    }
    
    return YES;
    
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{

}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
{
    
}

- (void)SkipNextViewControll
{
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    [userDefault setObject:@"YES" forKey:FIRSTLOGIN];
    [userDefault synchronize];
    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    ZTTabBarController *tab = [[ZTTabBarController alloc] init];
    window.rootViewController = tab;

}

@end
